package com.TwinBlade.PicturePassword;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.TypedArray;
import android.preference.Preference;
import android.preference.PreferenceManager;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;

public class SeekBarPreference extends Preference
  implements SeekBar.OnSeekBarChangeListener
{
  private final String a = getClass().getName();
  private int b = 100;
  private int c = 0;
  private int d = 1;
  private int e;
  private String f = "";
  private String g = "";
  private SeekBar h;
  private String i;
  private TextView j;
  private Context k;

  public SeekBarPreference(Context paramContext, AttributeSet paramAttributeSet)
  {
    super(paramContext, paramAttributeSet);
    this.k = paramContext;
    a(paramContext, paramAttributeSet);
  }

  public SeekBarPreference(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
  {
    super(paramContext, paramAttributeSet, paramInt);
    this.k = paramContext;
    a(paramContext, paramAttributeSet);
  }

  private String a(AttributeSet paramAttributeSet, String paramString1, String paramString2, String paramString3)
  {
    String str = paramAttributeSet.getAttributeValue(paramString1, paramString2);
    if (str == null)
      return paramString3;
    return str;
  }

  private void a(Context paramContext, AttributeSet paramAttributeSet)
  {
    a(paramAttributeSet);
    this.h = new SeekBar(paramContext, paramAttributeSet);
    this.h.setMax(this.b - this.c);
    this.h.setOnSeekBarChangeListener(this);
  }

  private void a(AttributeSet paramAttributeSet)
  {
    this.b = paramAttributeSet.getAttributeIntValue("http://schemas.android.com/apk/res/android", "max", 100);
    this.c = paramAttributeSet.getAttributeIntValue("http://robobunny.com", "min", 0);
    this.f = a(paramAttributeSet, "http://robobunny.com", "unitsLeft", "");
    this.g = a(paramAttributeSet, "http://robobunny.com", "unitsRight", a(paramAttributeSet, "http://robobunny.com", "units", ""));
    this.i = a(paramAttributeSet, "http://schemas.android.com/apk/res/android", "key", "null");
    try
    {
      String str = paramAttributeSet.getAttributeValue("http://robobunny.com", "interval");
      if (str != null)
        this.d = Integer.parseInt(str);
      return;
    }
    catch (Exception localException)
    {
      Log.e(this.a, "Invalid interval value", localException);
    }
  }

  protected void a(View paramView)
  {
    while (true)
    {
      try
      {
        RelativeLayout localRelativeLayout = (RelativeLayout)paramView;
        this.j = ((TextView)localRelativeLayout.findViewById(2131230760));
        this.j.setText(String.valueOf(this.e));
        this.j.setMinimumWidth(30);
        this.h.setProgress(this.e - this.c);
        ((TextView)localRelativeLayout.findViewById(2131230759)).setText(this.g);
        ((TextView)localRelativeLayout.findViewById(2131230761)).setText(this.f);
        SharedPreferences localSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this.k);
        if (this.i.equals("TimeFontSize"))
        {
          this.h.setEnabled(localSharedPreferences.getBoolean("InfoPanel", false));
          return;
        }
        if (!this.i.equals("ExtraFontSize"))
          break;
        SeekBar localSeekBar = this.h;
        if ((localSharedPreferences.getBoolean("InfoDateBattery", false)) && (localSharedPreferences.getBoolean("InfoPanel", false)))
        {
          bool = true;
          localSeekBar.setEnabled(bool);
          return;
        }
      }
      catch (Exception localException)
      {
        Log.e(this.a, "Error updating seek bar preference", localException);
        return;
      }
      boolean bool = false;
    }
    if ((this.i.equals("LockDelayMinute")) || (this.i.equals("LockDelaySecond")))
      this.h.setEnabled(bd.a(this.k));
  }

  public void onBindView(View paramView)
  {
    super.onBindView(paramView);
    try
    {
      ViewParent localViewParent = this.h.getParent();
      ViewGroup localViewGroup = (ViewGroup)paramView.findViewById(2131230762);
      if (localViewParent != localViewGroup)
      {
        if (localViewParent != null)
          ((ViewGroup)localViewParent).removeView(this.h);
        localViewGroup.removeAllViews();
        localViewGroup.addView(this.h, -1, -2);
      }
      a(paramView);
      return;
    }
    catch (Exception localException)
    {
      while (true)
        Log.e(this.a, "Error binding view: " + localException.toString());
    }
  }

  protected View onCreateView(ViewGroup paramViewGroup)
  {
    try
    {
      RelativeLayout localRelativeLayout = (RelativeLayout)((LayoutInflater)getContext().getSystemService("layout_inflater")).inflate(2130903048, paramViewGroup, false);
      return localRelativeLayout;
    }
    catch (Exception localException)
    {
      Log.e(this.a, "Error creating seek bar preference", localException);
    }
    return null;
  }

  protected Object onGetDefaultValue(TypedArray paramTypedArray, int paramInt)
  {
    return Integer.valueOf(paramTypedArray.getInt(paramInt, 50));
  }

  public void onProgressChanged(SeekBar paramSeekBar, int paramInt, boolean paramBoolean)
  {
    int m = paramInt + this.c;
    if (m > this.b)
      m = this.b;
    while (!callChangeListener(Integer.valueOf(m)))
    {
      paramSeekBar.setProgress(this.e - this.c);
      return;
      if (m < this.c)
        m = this.c;
      else if ((this.d != 1) && (m % this.d != 0))
        m = Math.round(m / this.d) * this.d;
    }
    this.e = m;
    this.j.setText(String.valueOf(m));
    persistInt(m);
  }

  protected void onSetInitialValue(boolean paramBoolean, Object paramObject)
  {
    if (paramBoolean)
    {
      this.e = getPersistedInt(this.e);
      return;
    }
    try
    {
      int n = ((Integer)paramObject).intValue();
      m = n;
      persistInt(m);
      this.e = m;
      return;
    }
    catch (Exception localException)
    {
      while (true)
      {
        Log.e(this.a, "Invalid default value: " + paramObject.toString());
        int m = 0;
      }
    }
  }

  public void onStartTrackingTouch(SeekBar paramSeekBar)
  {
  }

  public void onStopTrackingTouch(SeekBar paramSeekBar)
  {
    notifyChanged();
  }
}

/* Location:           D:\Studium\Bachelorarbeit\BA Marcus Wobig\BA\BA\Decompiler\PicturePassword APK\Programm\PicturePassword_dex2jar.jar
 * Qualified Name:     com.TwinBlade.PicturePassword.SeekBarPreference
 * JD-Core Version:    0.6.2
 */